/**
 * RepeatString<T,C>
 * 复制字符T为字符串类型，长度为C
 */

// 将字符串类型的元素转换为字符串字面量类型
type TupleToString<T extends string[], Prev extends string = ''> = T extends [infer L, ...infer R] ? (L extends `${infer LL}` ? TupleToString<R, `${Prev}${LL}`> : '') : Prev
// 重复元组
type Repeat<StringTuple extends string[], Len extends number, Char extends string> = StringTuple["length"] extends Len ? TupleToString<StringTuple> : Repeat<[...StringTuple, Char], Len, Char>
// 重复字符串
type RepeatString<Str extends string, Len extends number> = Len extends 0 ? '' : Repeat<[Str], Len, Str>
type A = RepeatString<'a', 3> // 'aaa'
type B = RepeatString<'a', 0> // ''
type C = RepeatString<'a', 2> // ''

export {}